import random
import os

def gen_video_path(suffix='.mp4'):
	return gen_path('/video' , suffix)
def gen_epub_path(suffix='.epub'):
	return gen_path('/epub' , suffix)
	

def gen_path(prefix='',suffix=''):
	return prefix+'/'+random_16(2)+'/'+random_16(2)+'/'+random_az(20)+suffix

def random_str(n , seq='0123456789abcdef'):
	return ''.join([seq[random.randint(0,len(seq)-1)] for i in range(n)])
def random_16(n):
	return random_str(n , seq='0123456789abcdef')
def random_az(n):
	return random_str(n , seq='abcdefghijklmnopqrstuvwxyz') 

def ensure_dirs(path):
	dir_path = os.path.dirname(path)
	if not os.path.exists(dir_path):
		os.makedirs(dir_path)
